package com.mashibing.apiboss.controller;

import com.mashibing.apiboss.service.DriverUserService;
import com.mashibing.internalcommon.dto.Car;
import com.mashibing.internalcommon.dto.DriverCarBindingRelationship;
import com.mashibing.internalcommon.dto.DriverUser;
import com.mashibing.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @title: DriverUserController
 * @Author Z先森
 * @Date: 2022/9/28 10:43
 * @Version 1.0
 */
@RestController
public class DriverUserController {
    @Autowired
    private DriverUserService driverUserService;

    /**
     * 添加司机信息
     * @param driverUser
     * @return
     */
    @PostMapping("/driver-user")
    public ResponseResult addDriverUser(@RequestBody DriverUser driverUser){
        driverUserService.addUser(driverUser);
        return ResponseResult.success("");
    }

    /**
     * 修改司机信息
     * @param driverUser
     * @return
     */
    @PutMapping("/driver-user")
    public ResponseResult updateDriverUser(@RequestBody DriverUser driverUser){
        driverUserService.updateDriverUser(driverUser);
        return ResponseResult.success("");
    }

    /**
     * 添加车辆信息
     * @param car
     * @return
     */
    @PostMapping("/car")
    public ResponseResult addCar(@RequestBody Car car){
        return driverUserService.addCar(car);
    }

    /**
     * 司机车辆绑定
     * @param driverCarBindingRelationship
     * @return
     */
    @PostMapping("/bind")
    public ResponseResult bind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverUserService.bind(driverCarBindingRelationship);
    }

    /**
     * 司机车辆解绑
     * @param driverCarBindingRelationship
     * @return
     */
    @PostMapping("/unBind")
    public ResponseResult unBind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverUserService.unBind(driverCarBindingRelationship);
    }

}
